package org.jivesoftware.smackx.provider;

import java.util.ArrayList;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.RemoteRosterEntry;
import org.jivesoftware.smackx.packet.RosterExchange;
import org.xmlpull.v1.XmlPullParser;

public class RosterExchangeProvider
  implements PacketExtensionProvider
{
  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    RosterExchange localRosterExchange = new RosterExchange();
    int i = 0;
    String str1 = "";
    String str2 = "";
    ArrayList localArrayList = new ArrayList();
    while (true)
    {
      do
      {
        int j;
        label123: 
        do
          while (true)
          {
            do
            {
              if (i != 0)
                return localRosterExchange;
              j = paramXmlPullParser.next();
              if (j != 2)
                break label123;
              if (paramXmlPullParser.getName().equals("item"))
              {
                localArrayList = new ArrayList();
                str1 = paramXmlPullParser.getAttributeValue("", "jid");
                str2 = paramXmlPullParser.getAttributeValue("", "name");
              }
            }
            while (!(paramXmlPullParser.getName().equals("group")));
            localArrayList.add(paramXmlPullParser.nextText());
          }
        while (j != 3);
        if (paramXmlPullParser.getName().equals("item"))
          localRosterExchange.addRosterEntry(new RemoteRosterEntry(str1, str2, (String[])localArrayList.toArray(new String[localArrayList.size()])));
      }
      while (!(paramXmlPullParser.getName().equals("x")));
      i = 1;
    }
  }
}